package com.youyi.yyviewsdklibrary.Dialog.core;

import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import com.youyi.yyviewsdklibrary.Dialog.animator.PopupAnimator;
import com.youyi.yyviewsdklibrary.Dialog.enums.PopupPosition;
import com.youyi.yyviewsdklibrary.Dialog.enums.PopupStatus;
import com.youyi.yyviewsdklibrary.Dialog.util.KeyboardUtils;
import com.youyi.yyviewsdklibrary.Dialog.util.XPopupUtils;
import com.youyi.yyviewsdklibrary.Dialog.widget.PopupDrawerLayout;
import com.lkx.liandianqinew.R;

public abstract class DrawerPopupView extends BasePopupView {
    public ArgbEvaluator argbEvaluator = new ArgbEvaluator();
    int currColor = 0;
    int defaultColor = 0;
    protected FrameLayout drawerContentContainer = ((FrameLayout) findViewById(R.id.drawerContentContainer));
    protected PopupDrawerLayout drawerLayout = ((PopupDrawerLayout) findViewById(R.id.drawerLayout));
    float mFraction = 0.0f;
    Paint paint = new Paint();
    Rect shadowRect;

    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public void doDismissAnimation() {
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public PopupAnimator getPopupAnimator() {
        return null;
    }

    public DrawerPopupView(Context context) {
        super(context);
    }

    /* access modifiers changed from: protected */
    public void addInnerContent() {
        this.drawerContentContainer.addView(LayoutInflater.from(getContext()).inflate(getImplLayoutId(), (ViewGroup) this.drawerContentContainer, false));
    }

    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public View getPopupImplView() {
        return this.drawerContentContainer.getChildAt(0);
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public final int getInnerLayoutId() {
        return R.layout._xpopup_drawer_popup_view;
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public void initPopupContent() {
        super.initPopupContent();
        if (this.drawerContentContainer.getChildCount() == 0) {
            addInnerContent();
        }
        this.drawerLayout.isDismissOnTouchOutside = this.popupInfo.isDismissOnTouchOutside.booleanValue();
        this.drawerLayout.setOnCloseListener(new PopupDrawerLayout.OnCloseListener() {
            /* class com.youyi.yyviewsdklibrary.Dialog.core.DrawerPopupView.AnonymousClass1 */

            @Override // com.youyi.yyviewsdklibrary.Dialog.widget.PopupDrawerLayout.OnCloseListener
            public void onOpen() {
            }

            @Override // com.youyi.yyviewsdklibrary.Dialog.widget.PopupDrawerLayout.OnCloseListener
            public void onClose() {
                DrawerPopupView.this.beforeDismiss();
                if (!(DrawerPopupView.this.popupInfo == null || DrawerPopupView.this.popupInfo.xPopupCallback == null)) {
                    DrawerPopupView.this.popupInfo.xPopupCallback.beforeDismiss(DrawerPopupView.this);
                }
                DrawerPopupView.this.doAfterDismiss();
            }

            @Override // com.youyi.yyviewsdklibrary.Dialog.widget.PopupDrawerLayout.OnCloseListener
            public void onDrag(int i, float f, boolean z) {
                if (DrawerPopupView.this.popupInfo != null) {
                    if (DrawerPopupView.this.popupInfo.xPopupCallback != null) {
                        DrawerPopupView.this.popupInfo.xPopupCallback.onDrag(DrawerPopupView.this, i, f, z);
                    }
                    DrawerPopupView.this.mFraction = f;
                    if (DrawerPopupView.this.popupInfo.hasShadowBg.booleanValue()) {
                        DrawerPopupView.this.shadowBgAnimator.applyColorValue(f);
                    }
                    DrawerPopupView.this.postInvalidate();
                }
            }
        });
        getPopupImplView().setTranslationX((float) this.popupInfo.offsetX);
        getPopupImplView().setTranslationY((float) this.popupInfo.offsetY);
        this.drawerLayout.setDrawerPosition(this.popupInfo.popupPosition == null ? PopupPosition.Left : this.popupInfo.popupPosition);
        this.drawerLayout.enableDrag = this.popupInfo.enableDrag.booleanValue();
        this.drawerLayout.getChildAt(0).setOnClickListener(new OnClickListener() {
            /* class com.youyi.yyviewsdklibrary.Dialog.core.DrawerPopupView.AnonymousClass2 */

            public void onClick(View view) {
                if (DrawerPopupView.this.popupInfo != null) {
                    if (DrawerPopupView.this.popupInfo.xPopupCallback != null) {
                        DrawerPopupView.this.popupInfo.xPopupCallback.onClickOutside(DrawerPopupView.this);
                    }
                    if (DrawerPopupView.this.popupInfo.isDismissOnTouchOutside != null) {
                        DrawerPopupView.this.dismiss();
                    }
                }
            }
        });
    }

    /* access modifiers changed from: protected */
    public void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
        if (this.popupInfo != null && this.popupInfo.hasStatusBarShadow.booleanValue()) {
            if (this.shadowRect == null) {
                this.shadowRect = new Rect(0, 0, getMeasuredWidth(), XPopupUtils.getStatusBarHeight());
            }
            this.paint.setColor(((Integer) this.argbEvaluator.evaluate(this.mFraction, Integer.valueOf(this.defaultColor), Integer.valueOf(getStatusBarBgColor()))).intValue());
            canvas.drawRect(this.shadowRect, this.paint);
        }
    }

    public void doStatusBarColorTransform(boolean z) {
        int i;
        if (this.popupInfo != null && this.popupInfo.hasStatusBarShadow.booleanValue()) {
            ArgbEvaluator argbEvaluator2 = this.argbEvaluator;
            Object[] objArr = new Object[2];
            int i2 = 0;
            if (z) {
                i = 0;
            } else {
                i = getStatusBarBgColor();
            }
            objArr[0] = Integer.valueOf(i);
            if (z) {
                i2 = getStatusBarBgColor();
            }
            objArr[1] = Integer.valueOf(i2);
            ValueAnimator ofObject = ValueAnimator.ofObject(argbEvaluator2, objArr);
            ofObject.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                /* class com.youyi.yyviewsdklibrary.Dialog.core.DrawerPopupView.AnonymousClass3 */

                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    DrawerPopupView.this.currColor = ((Integer) valueAnimator.getAnimatedValue()).intValue();
                    DrawerPopupView.this.postInvalidate();
                }
            });
            ofObject.setDuration((long) getAnimationDuration()).start();
        }
    }

    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public void doShowAnimation() {
        this.drawerLayout.open();
        doStatusBarColorTransform(true);
    }

    /* access modifiers changed from: protected */
    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public void doAfterDismiss() {
        if (this.popupInfo != null && this.popupInfo.autoOpenSoftInput.booleanValue()) {
            KeyboardUtils.hideSoftInput(this);
        }
        this.handler.removeCallbacks(this.doAfterDismissTask);
        this.handler.postDelayed(this.doAfterDismissTask, 0);
    }

    @Override // com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView
    public void dismiss() {
        if (this.popupInfo != null && this.popupStatus != PopupStatus.Dismissing) {
            this.popupStatus = PopupStatus.Dismissing;
            if (this.popupInfo.autoOpenSoftInput.booleanValue()) {
                KeyboardUtils.hideSoftInput(this);
            }
            clearFocus();
            doStatusBarColorTransform(false);
            this.drawerLayout.close();
        }
    }
}
